home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: Schildt <- Advanced Books
- Date: 6 Mar 96 14:12:08 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.826121528@rscernix>
- References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <4gnt96INN205@keats.ugrad.cs.ubc.ca> <4h4q0v$24v@redstone.interpath.net> <danpop.825687663@rscernix> <4he6hb$ahn@solutions.solon.com>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4he6hb$ahn@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes:
-
- >In article <danpop.825687663@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
- >>Sorry, I can hardly believe that. Here are two examples (originally
- >>posted by Lawrence Kirby) from page 53 of the _third_ edition of C-TCR:
- >
- >> float f
- >> printf("%f ", sizeof f);
- >> printf("%d", sizeof(int));
- >>
- >>Both mistakes appeared in the second edition of the book, as well, and
- >>they are NOT typos. Ideally, the author shouldn't be allowed to
- >>publish anything on a topic he is utterly unable to understand.
- >>Unfortunately, the market realities of today are far from ideal :-(
- >
- >I could consider the "%f" a typo; it is when I do it.
-
- "%f" might be a typo (yet it was preserved between editions, so maybe
- it was not a typo :-) but the missing cast _cannot_ be a typo.
-
- >The others are
- >stunning; the size_t vs int bug is subtle.
-
- There is nothing subtle here, for someone who knows C (which rules Schildt
- out :-) size_t is _guaranteed_ not to be defined as int, so using "%d"
- is plain idiotic. I could understand a "%u", and qualify the author as
- mildly stupid :-)
-
-
- >The sizeof(ptr) bug is idiotic.
-
- Every single bit as idiotic as "%d" for size_t. Under special
- circumstances, both give the "correct" results. At least, sizeof(ptr)
- doesn't invoke undefined behaviour :-)
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-